package com.fh.service;

import com.fh.dto.WebSocketClientDto;
import org.java_websocket.client.WebSocketClient;

import java.net.URI;
import java.net.URISyntaxException;

/**
 * @author whf
 * @date 2024年03月13日 15:30
 */
public class A {

    private static WebSocketClient client = null;

    public static void main(String[] args) {

        WebSocketClient client = getC();
        client.connect();


    }

    public static WebSocketClient getC() {
        if(client != null) {
            return client;
        }
        String serverUrl = "ws://localhost:8888/websocket/fh"; // WebSocket服务器地址
        try {
            client = new WebSocketClientDto(new URI(serverUrl));

            client.connect(); // 建立WebSocket连接


        } catch(URISyntaxException e) {
            e.printStackTrace();
        }
        return client;
    }

}
